

package org.come.Jpanel;

import com.tool.image.ImageMixDeal;
import com.tool.role.ExpUtil;
import com.tool.role.RoleLingFa;
import com.tool.tcpimg.ChatBox;
import com.tool.tcpimg.UIUtils;
import come.tool.FightingData.FBUtil;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.LayoutManager;
import java.math.BigDecimal;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import org.come.bean.Skill;
import org.come.entity.Goodstable;
import org.come.model.Lingbao;
import org.come.until.AnalysisString;
import org.come.until.GoodsListFromServerUntil;
import org.come.until.UserData;
import org.come.until.UserMessUntil;



public class LingMsgJpanel extends JPanel {
	private JLabel quality = new JLabel();
	private JLabel baoname;
	private JLabel baolvl;
	private JLabel baotext;
	private ChatBox bao = new ChatBox();
	private JLabel fushi;
	private JLabel[] fushiimg = new JLabel[5];
	private ChatBox shi = new ChatBox();
	private JLabel tianfu;
	private JLabel shanchang1;
	private JLabel shanchang2;
	private JLabel skill;
	private JLabel[] skillimg = new JLabel[5];
	private JLabel[] skillname = new JLabel[5];
	private ImageIcon kaiqi = new ImageIcon("inkImg/old/lingbao/msg/小开.png");
	private ImageIcon guanbi = new ImageIcon("inkImg/old/lingbao/msg/小封.png");
	private ImageIcon fushikaiqi = new ImageIcon("inkImg/old/lingbao/msg/小圆开.png");
	private ImageIcon fushiguanbi = new ImageIcon("inkImg/old/lingbao/msg/小圆封.png");
	private ImageIcon icon;
	private ImageIcon lingimg;

	public LingMsgJpanel() {
		this.quality.setBounds(15, 5, 90, 25);
		this.quality.setForeground(new Color(205, 79, 57));
		this.quality.setFont(UIUtils.TEXT_MSG);
		this.quality.setHorizontalAlignment(0);
		this.quality.setVerticalAlignment(0);
		this.add(this.quality);
		this.baoname = new JLabel();
		this.baoname.setBounds(110, 5, 55, 25);
		this.baoname.setFont(UIUtils.TEXT_MSG);
		this.baoname.setForeground(Color.WHITE);
		this.add(this.baoname);
		this.baolvl = new JLabel();
		this.baolvl.setBounds(165, 5, 80, 25);
		this.baolvl.setFont(UIUtils.TEXT_MSG);
		this.baolvl.setForeground(new Color(205, 79, 57));
		this.add(this.baolvl);
		this.baotext = new JLabel();
		this.baotext.setBounds(110, 30, 300, 25);
		this.baotext.setFont(UIUtils.TEXT_MSG);
		this.baotext.setForeground(Color.WHITE);
		this.add(this.baotext);
		this.fushi = new JLabel();
		this.fushi.setBounds(110, 150, 30, 25);
		this.fushi.setFont(UIUtils.TEXT_MSG);
		this.fushi.setForeground(new Color(210, 180, 140));
		this.fushi.setText("符石");
		this.add(this.fushi);

		int i;
		for(i = 0; i < 5; ++i) {
			this.fushiimg[i] = new JLabel();
			this.fushiimg[i].setBounds(145, 152 + i * 20, 18, 18);
			this.add(this.fushiimg[i]);
		}
		//天赋技能
		this.tianfu = new JLabel();
		this.tianfu.setBounds(110, 250, 300, 25);
		this.tianfu.setFont(UIUtils.TEXT_MSG);
		this.tianfu.setForeground(new Color(164, 211, 238));
		this.tianfu.setText("天赋技能: 低级根骨灰色  低级根骨灰色");
		this.add(this.tianfu);
		//擅长技能技能
		this.shanchang1 = new JLabel();
		this.shanchang1.setBounds(110, 270, 300, 25);
		this.shanchang1.setFont(UIUtils.TEXT_MSG);
		this.shanchang1.setForeground(new Color(162, 181, 205));
		this.shanchang1.setText("擅长技能: 低级根骨  低级根骨  低级根骨");
		this.add(this.shanchang1);
		this.shanchang2 = new JLabel();
		this.shanchang2.setBounds(175, 290, 300, 25);
		this.shanchang2.setFont(UIUtils.TEXT_MSG);
		this.shanchang2.setForeground(new Color(162, 181, 205));
		this.shanchang2.setText("低级根骨  低级根骨  低级根骨");
		this.add(this.shanchang2);
		//技能
		this.skill = new JLabel();
		this.skill.setBounds(15, 160, 90, 25);
		this.skill.setForeground(new Color(238, 232, 205));
		this.skill.setFont(UIUtils.TEXT_MSG);
		this.skill.setHorizontalAlignment(0);
		this.skill.setVerticalAlignment(0);
		this.skill.setText("技能");
		this.add(this.skill);

		for(i = 0; i < 5; ++i) {
			this.skillimg[i] = new JLabel();
			this.skillimg[i].setBounds(15, 185 + i * 20, 20, 20);
			ImageIcon img = new ImageIcon("img/灵宝/skill/疾风骤雨.png");
			img.setImage(img.getImage().getScaledInstance(20, 20, 1));
			this.skillimg[i].setIcon(img);
			this.add(this.skillimg[i]);
			this.skillname[i] = new JLabel();
			this.skillname[i].setBounds(40, 176 + i * 21, 60, 30);
			this.skillname[i].setFont(UIUtils.TEXT_MSG);
			this.skillname[i].setForeground(new Color(162, 181, 205));
			this.skillname[i].setText("疾风骤雨");
			this.add(this.skillname[i]);
		}

		this.setPreferredSize(new Dimension(470, 320));
		this.setLayout((LayoutManager)null);
		this.setBackground(new Color(0, 0, 0, 0));
	}

	@Override
    protected void paintComponent(Graphics g) {
		// TODO Auto-generated method stub
		super.paintComponent(g);
		if (PetsMsgJpanel.icon==null){
		if (PetsMsgJpanel.icon==null)PetsMsgJpanel.icon=new ImageIcon("inkImg/newbackground/S301.png");
		}

		g.drawImage(PetsMsgJpanel.icon.getImage(), 0,0,470,320, this);
		if (lingimg!=null) {
			g.drawImage(lingimg.getImage(), 10, 30, 96, 96, this);
		}
		Graphics g2 = g.create(110,30,360,125);
		bao.paint(g2);
		g2.dispose();
		Graphics g3 = g.create(180,150,285,105);
		shi.paint(g3);
		g3.dispose();
	}

	public void lingbaoshow(Lingbao lingbao) {
		this.quality.setText("品质  " + lingbao.getBaoquality());
		this.baoname.setText(lingbao.getBaoname());
		this.baolvl.setText(lingbao.getLingbaolvl() + " 级");
		this.baotext.setText(" ");
		this.lingimg = RoleLingFa.lingbaoimg(lingbao.getSkin(), -1, -1);
		if ("法宝".equals(lingbao.getBaotype())) {
			this.showfb(lingbao);
		} else {
			if (lingbao.getTianfuskill() == null) {
				lingbao.setTianfuskill("");
			}

			String[] tianv = lingbao.getTianfuskill().split("\\|");
			StringBuffer tianb = new StringBuffer();
			tianb.append("天赋技能:");

			for(int i = 0; i < tianv.length; ++i) {
				tianb.append(" " + tianv[i]);
			}

			this.tianfu.setText(tianb.toString());
			String[] shanb = null;
			if (lingbao.getGoodskill() != null && !"".equals(lingbao.getGoodskill())) {
				shanb = lingbao.getGoodskill().split("\\|");
			}

			StringBuffer tianb1 = new StringBuffer();
			tianb1.append("擅长技能:");
			if (shanb != null) {
				for(int i = 0; i < shanb.length && i < 3; ++i) {
					tianb1.append(" " + shanb[i]);
				}
			}

			this.shanchang1.setText(tianb1.toString());
			StringBuffer tianb2 = new StringBuffer();
			int i;
			if (shanb != null && shanb.length >= 3) {
				for(i = 3; i < shanb.length; ++i) {
					tianb2.append(" " + shanb[i]);
				}
			}

			this.shanchang2.setText(tianb2.toString());
			this.bao.removemsg();
			this.bao.addText("#G契合度" + lingbao.getLingbaoqihe() + " 活跃度" + lingbao.hyz() + "#W(" + lingbao.getBaoactive() + ")", 350);
			this.bao.addText("#G速度" + lingbao.spz() + "#W(" + lingbao.getBaospeed() + ")" + " #G援助" + UserData.xiaoshu(lingbao.zyz() * 1000.0D / 10.0D) + "#W(" + UserData.xiaoshu(lingbao.getAssistance() * 1000.0D / 10.0D) + ")", 350);
			this.bao.addText("#G回复" + UserData.xiaoshu(lingbao.replyz() * 1000.0D / 10.0D) + "#W(" + UserData.xiaoshu(Double.parseDouble(lingbao.getBaoreply()) * 1000.0D / 10.0D) + ")" + " #G落宝" + UserData.xiaoshu(lingbao.shotz() * 1000.0D / 10.0D) + "#W(" + UserData.xiaoshu(lingbao.getBaoshot() * 1000.0D / 10.0D) + ")", 350);
			this.bao.addText("#G伤害" + UserData.xiaoshu(lingbao.apz() * 1000.0D / 10.0D) + "#W(" + UserData.xiaoshu(Double.parseDouble(lingbao.getBaoap()) * 1000.0D / 10.0D) + ")" + " #G抗落宝" + UserData.xiaoshu(lingbao.resistshopz() * 1000.0D / 10.0D) + "#W(" + UserData.xiaoshu(lingbao.getResistshop() * 1000.0D / 10.0D) + ")", 350);
			this.bao.addText("#Y" + lingbao.getKangxing().split("=")[0] + " " + lingbao.getKangxing().split("=")[1], 350);
			this.bao.addText("#Y道行:#R" + ExpUtil.LFExptoString(lingbao.getLingbaoexe().longValue() + ExpUtil.LFExp2(lingbao.getLingbaolvl().intValue() - 1)) + "/" + ExpUtil.LFExptoString(ExpUtil.LFExp2(lingbao.getLingbaolvl().intValue())), 350, UIUtils.TEXT_FONT1);
			shanb = null;
			if (lingbao.getSkills() != null && !"".equals(lingbao.getSkills())) {
				shanb = lingbao.getSkills().split("\\|");
			}

			for(i = 0; i < 5; ++i) {
				if (i < lingbao.getSkillsum()) {
					if (shanb != null && i < shanb.length) {
						this.skillxiugai(i, shanb[i].split("=")[0]);
					} else {
						this.skillxiugai(i, "已开启");
					}
				} else {
					this.skillxiugai(i, "未开启");
				}
			}

			shanb = null;
			if (lingbao.getFushis() != null && !"".equals(lingbao.getFushis())) {
				shanb = lingbao.getFushis().split("\\|");
			}

			this.shi.removemsg();

			for(i = 0; i < 5; ++i) {
				if (i >= lingbao.getFusum()) {
					this.fushixiugai(i, "#cD2B48C未开启", this.fushiguanbi);
				} else if (shanb != null && i < shanb.length) {
					BigDecimal key = new BigDecimal(shanb[i]);
					Goodstable goodstable = (Goodstable)GoodsListFromServerUntil.fushis.get(key);
					if(goodstable == null){
						goodstable = lingbao.getFushiMap().get(key);
					}
					if (goodstable != null) {
						String[] vfu = goodstable.getValue().split("\\|");
						StringBuffer fua = new StringBuffer();
						fua.append("#cD2B48C");

						for(int j = 0; j < vfu.length; ++j) {
							if (j == 0) {
								fua.append("[" + vfu[j].split("=")[1] + "]");
							} else {
								fua.append(vfu[j].split("=")[0] + vfu[j].split("=")[1]);
							}
						}

						this.fushixiugai(i, fua.toString(), new ImageIcon("inkImg/old/lingbao/msg/" + goodstable.getSkin() + ".png"));
					}
				} else {
					this.fushixiugai(i, "#cD2B48C已开启", this.fushikaiqi);
				}
			}

		}
	}

	public void showfb(Lingbao lingbao) {
		StringBuffer tianb = new StringBuffer();
		tianb.append("天赋技能:");
		tianb.append(lingbao.getBaoname());
		this.tianfu.setText(tianb.toString());
		this.shanchang1.setText("擅长技能:无");
		this.shanchang2.setText("");
		this.shi.removemsg();
		this.bao.removemsg();

		for(int i = 0; i < 5; ++i) {
			this.skillxiugai(i, "无法开启");
			this.fushixiugai(i, "#cD2B48C无法开启", this.fushiguanbi);
		}

		this.bao.addText("#Y" + lingbao.getKangxing().split("=")[0] + " " + lingbao.getKangxing().split("=")[1], 350);
		this.bao.addText("#Y道行:#R" + ExpUtil.LFExptoString(lingbao.getLingbaoexe().longValue() + ExpUtil.LFExp2(lingbao.getLingbaolvl().intValue() - 1)) + "/" + ExpUtil.LFExptoString(ExpUtil.LFExp2(lingbao.getLingbaolvl().intValue())), 350, UIUtils.TEXT_FONT1);
		Skill skill = UserMessUntil.getskill1(lingbao.getBaoname());
		if (skill != null) {
			int id = Integer.parseInt(skill.getSkillid());
			int born = ImageMixDeal.userimg.getRoleShow().getTurnAround();
			int lvl = AnalysisString.lvlint(ImageMixDeal.userimg.getRoleShow().getGrade());
			int bzlvl = RoleLingFa.getRoleLingFa().getFaPJ();
			int qv = RoleLingFa.getQv(lingbao.getBaoquality());
			int blvl = lingbao.getLingbaolvl().intValue();
			int pz = FBUtil.getFBlvl(born, lvl, bzlvl, qv, blvl);
			double grow = 0.0D;
			double value = 0.0D;
			if (skill.getGrow() != null && !"".equals(skill.getGrow())) {
				grow = Double.parseDouble(skill.getGrow());
			}

			if (skill.getValue() != null && !"".equals(skill.getGrow())) {
				value = Double.parseDouble(skill.getValue());
			}

			String v1 = UserData.xiaoshu(value + (double)pz * grow);
			String v2 = String.valueOf(FBUtil.getFBcx(id, blvl));
			String v3 = null;
			String v4 = String.valueOf(FBUtil.getFBsum(id, blvl));
			if (id == 4014) {
				v3 = String.valueOf((int)((value + (double)pz * grow) * 12500.0D));
			} else if (id == 4015) {
				v3 = UserData.xiaoshu((value + (double)pz * grow) * 2.0D / 3.0D);
			}

			String v = skill.getRemark();
			v = v.replace("{概率}", v1);
			v = v.replace("{回合}", v2);
			if (v3 != null) {
				v = v.replace("{数值}", v3);
			}

			v = v.replace("{目标}", v4);
			this.bao.addText(v, 350);
		}

	}

	public void fushixiugai(int i, String text, ImageIcon imageIcon) {
		this.shi.addText(text, 285);
		this.fushiimg[i].setIcon(imageIcon);
	}

	public void skillxiugai(int i, String skill) {
		ImageIcon imageIcon = null;
		if ("已开启".equals(skill)) {
			imageIcon = this.kaiqi;
		} else if (!"未开启".equals(skill) && !"无法开启".equals(skill)) {
			imageIcon = new ImageIcon("inkImg/old/lingbao/skill/" + skill + ".png");
		} else {
			imageIcon = this.guanbi;
		}

		imageIcon.setImage(imageIcon.getImage().getScaledInstance(20, 20, 1));
		this.skillimg[i].setIcon(imageIcon);
		this.skillname[i].setText(skill);
	}

	public JLabel getQuality() {
		return this.quality;
	}

	public void setQuality(JLabel quality) {
		this.quality = quality;
	}

	public JLabel getBaoname() {
		return this.baoname;
	}

	public void setBaoname(JLabel baoname) {
		this.baoname = baoname;
	}

	public JLabel getBaolvl() {
		return this.baolvl;
	}

	public void setBaolvl(JLabel baolvl) {
		this.baolvl = baolvl;
	}

	public JLabel getBaotext() {
		return this.baotext;
	}

	public void setBaotext(JLabel baotext) {
		this.baotext = baotext;
	}

	public ChatBox getBao() {
		return this.bao;
	}

	public void setBao(ChatBox bao) {
		this.bao = bao;
	}

	public JLabel getFushi() {
		return this.fushi;
	}

	public void setFushi(JLabel fushi) {
		this.fushi = fushi;
	}

	public JLabel[] getFushiimg() {
		return this.fushiimg;
	}

	public void setFushiimg(JLabel[] fushiimg) {
		this.fushiimg = fushiimg;
	}

	public ChatBox getShi() {
		return this.shi;
	}

	public void setShi(ChatBox shi) {
		this.shi = shi;
	}

	public JLabel getTianfu() {
		return this.tianfu;
	}

	public void setTianfu(JLabel tianfu) {
		this.tianfu = tianfu;
	}

	public JLabel getShanchang1() {
		return this.shanchang1;
	}

	public void setShanchang1(JLabel shanchang1) {
		this.shanchang1 = shanchang1;
	}

	public JLabel getShanchang2() {
		return this.shanchang2;
	}

	public void setShanchang2(JLabel shanchang2) {
		this.shanchang2 = shanchang2;
	}

	public JLabel[] getSkillimg() {
		return this.skillimg;
	}

	public void setSkillimg(JLabel[] skillimg) {
		this.skillimg = skillimg;
	}

	public JLabel[] getSkillname() {
		return this.skillname;
	}

	public void setSkillname(JLabel[] skillname) {
		this.skillname = skillname;
	}
}
